package com.sky.mapper;

import com.sky.entity.DishFlavor;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishFlavorMapper {


    /**
     * 插入菜品风味
     *
     * @param flavors
     */
   /* @Insert("insert into dish_flavor(dish_id, name, value) " +
            "VALUES (#{dishId},#{name},#{value})")*/     //此时传过来的是一个多元素集合，需要遍历集合中的每个元素
    void insert(List<DishFlavor> flavors);


    /**
     * 根据菜品id删除相关的风味
     *
     * @param dishIds
     */
    void deleteByDishId(List<Long> dishIds);


    /**
     * 根据菜品id查询相关风味
     *
     * @param dishId
     * @return
     */
    @Select("select * from dish_flavor where dish_id = #{dishId}")
    List<DishFlavor> selectByDishId(Long dishId);


    /**
     * 根据id删除单条记录
     * @param id
     */
    @Delete("delete from dish_flavor where dish_id = #{dishId}")
    void delete(Long id);

}
